#ifndef _COLOR
#define _COLOR

// INCLUDES --------------------------------------------------------------------
#include "Base.h"

// DEFINES ---------------------------------------------------------------------

// TYPEDEFS --------------------------------------------------------------------

// RGBA floating point
typedef struct
{
	union
  { // red, green, blue, alpha
    fp r,g,b,a; // component style
    fp rgba[4]; // array style
	};
} ColorRGBA;

// RGB 8bit
typedef struct
{
	union
  { // red, green, blue
    i8 r,g,b;	 // component style
    i8 rgb[4]; // array style
	};
} ColorRGB8;

// FUNCTIONS -------------------------------------------------------------------

/* GENERAL:
   d    -> destination
   s    -> source
   size -> array size (0,1 for single elements)

   c    -> arbitrary color
   a,b  -> two arbitrary colors
   k    -> floating point scalar
*/
void ColorClear (ColorRGBA *c, ui32 size);                 // clear to [r:0,g:0,b:0,a:1]
void ColorCopy  (ColorRGBA *d, ColorRGBA *s, ui32 size);   // clone color src->dest

void ColorInvert(ColorRGBA *c);                            // -(c)

void ColorAdd  (ColorRGBA *d, ColorRGBA *a, ColorRGBA *b); // +
void ColorAddTo(ColorRGBA *d, ColorRGBA *a);               // +=

void ColorSub  (ColorRGBA *d, ColorRGBA *a, ColorRGBA *b); // -
void ColorSubTo(ColorRGBA *d, ColorRGBA *a);               // -=

void ColorMul  (ColorRGBA *d, ColorRGBA* a, fp k);         // *
void ColorMulTo(ColorRGBA *d, fp k);                       // *=

void ColorDiv  (ColorRGBA *d, ColorRGBA* a, fp k);         // /
void ColorDivTo(ColorRGBA *d, fp k);                       // /=

bool ColorEquals  (ColorRGBA *a, ColorRGBA *b);            // ==
bool ColorInEquals(ColorRGBA *a, ColorRGBA *b);            // !=

#endif // _COLOR
